#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

import os
import shutil


class PluginObject:

    def __init__(self, param, api):
        self.resolvConfFile = os.path.join(api.getRootDir(), "etc/resolv.conf")

    def stage_working_start_handler(self, requestObj):
        shutil.copyfile("/etc/resolv.conf", self.resolvConfFile)
        return {}

    def stage_working_end_handler(self):
        if os.path.exists(self.resolvConfFile):
            os.unlink(self.resolvConfFile)
